package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import lombok.Getter;

/**
 * 所有字段枚举
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/30 11:02
 * @since v1.0
 */
@Getter
public enum AllFieldEnum {
    // 模板设置界面展示字段
    NAME("text_1", "enum.allField.attrName.name", "name", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9990, 1, 1),
    CUSTOMER_NAME("text_2", "enum.allField.attrName.customer_name", "customerName", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9980, 1, 0),
    PHONE("subForm_1", "enum.allField.attrName.phone", "phone", FieldTypeEnum.CONTACT_NUMBER.getType(), 2, 0, 0, ShowTypeEnum.ALL.getCode(), 9970, 1, 0),
    LEVEL("text_3", "enum.allField.attrName.level", "level", FieldTypeEnum.COMBO.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9960, 1, 0),
    IMPORTANT_DEGREE("num_1", "enum.allField.attrName.important_degree", "importDegree", FieldTypeEnum.STAR.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9950, 1, 0),
    EMAIL("text_4", "enum.allField.attrName.email", "email", FieldTypeEnum.TEXT.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9940, 1, 0),
    ADDRESS("address_1", "enum.allField.attrName.address", "address", FieldTypeEnum.ADDRESS.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9930, 1, 0),
    ZIP_CODE("text_5", "enum.allField.attrName.zip_code", "zipCode", FieldTypeEnum.TEXT.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9920, 1, 0),
    BIRTHDAY("date_1", "enum.allField.attrName.birthday", "birthday", FieldTypeEnum.BIRTHDAY.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9910, 1, 0),
    MEMO("text_7", "enum.allField.attrName.memo", "memo", FieldTypeEnum.TEXTAREA.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9900, 1, 0),
    CUSTOMER_NAME_LINK_TEXT("text_8", "enum.allField.attrName.customer_name_link_text", "customerNameLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9890, 1, 0),
    CREATOR_ID("text_9", "enum.allField.attrName.creator_id", "creator_id", FieldTypeEnum.CREATORID.getType(), 1, 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9880, 1, 0),
    OUT_PRODUCTS("selectProduct_1", "enum.allField.attrName.out_products", "outProducts", FieldTypeEnum.SELECT_PRODUCT.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9870, 1, 0),
    INTO_WAREHOUSE_ID("text_10", "enum.allField.attrName.into_warehouse_id", "intoWarehouseId", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9860, 1, 0),
    SIGN_TIME("date_2", "enum.allField.attrName.sign_time", "signTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9850, 1, 0),
    SIGN_PERSON("text_11", "enum.allField.attrName.sign_person", "signPerson", FieldTypeEnum.USER.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9840, 1, 0),
    PAYMENT("subForm_2", "enum.allField.attrName.payment", "payment", FieldTypeEnum.SUB_FORM.getType(), 1, 0, 0, ShowTypeEnum.EDIT.getCode(), 9830, 1, 0),
    CONTRACT_NO("text_12", "enum.allField.attrName.contract_no", "contractNo", FieldTypeEnum.SERIALNO.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9820, 1, 0),
    VERSION("text_13", "enum.allField.attrName.version", "version", FieldTypeEnum.TEXT_CHECK.getType(), 4, 1, 0, ShowTypeEnum.ALL.getCode(), 9810, 1, 0),
    VIDEO("video_1", "enum.allField.attrName.video", "video", FieldTypeEnum.VIDEO.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9800, 1, 0),
    LOCATION("geo_1", "enum.allField.attrName.location", "address", FieldTypeEnum.LOCATION.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9790, 1, 0),
    IMAGES("file_1", "enum.allField.attrName.images", "images", FieldTypeEnum.IMAGE.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9780, 1, 0),
    MANAGER_ID("text_14", "enum.allField.attrName.manager_id", "managerId", FieldTypeEnum.OWNERID.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9770, 1, 0),
    CONTRACT_ID("text_15", "enum.allField.attrName.contract_id", "contractId", FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9760, 1, 0),
    ATTACHMENTS("file_2", "enum.allField.attrName.attachments", "attachments", FieldTypeEnum.UPLOAD.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9750, 1, 0),
    SPECIFICATION("text_16", "enum.allField.attrName.specification", "specification", FieldTypeEnum.SPECIFICATION.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9740, 1, 0),
    STOCK("text_17", "enum.allField.attrName.stock", "stock", FieldTypeEnum.PRODUCT_STOCK.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9730, 1, 0),
    INSTRUCTION("text_18", "enum.allField.attrName.instruction", "instruction", FieldTypeEnum.RICH_TEXT_EDITOR.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9720, 1, 0),
    APPROVED_PEOPLE("text_19", "enum.allField.attrName.approved_people", "approvedPeople", FieldTypeEnum.SELECT_DEPARTMENT.getType(), 1, 0, 0, ShowTypeEnum.EDIT.getCode(), 9710, 1, 0),
    THIS_PLAN("text_20", "enum.allField.attrName.this_plan", "thisPlan", FieldTypeEnum.SWITCH_TEXT.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9700, 1, 0),
    EXECUTOR("array_1", "enum.allField.attrName.executor", "executor", FieldTypeEnum.CHECKBOX_GROUP.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9690, 1, 0),
    CONTRACT_ID_LINK_TEXT("text_22", "enum.allField.attrName.contract_id_link_text", "contractIdLinkText", FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9680, 1, 0),
    BIRTHDAY_LINK_TEXT("num_2", "enum.allField.attrName.birthday_link_text", "birthdayLinkText", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9670, 1, 0),
    LUNAR_BIRTHDAY_LINK_TEXT("text_23", "enum.allField.attrName.lunar_birthday_link_text", "lunarBirthdayLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9660, 1, 0),
    VERSION_LINK_TEXT("num_3", "enum.allField.attrName.version_link_text", "versionLinkText", FieldTypeEnum.NUM.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9650, 1, 0),
    SPECIFICATION_LINK_TEXT("text_29", "enum.allField.attrName.specification_link_text", "specificationLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9640, 1, 0),
    COMMUNICATE_BUSINESS("text_24", "enum.allField.attrName.communicate_business", "communicateBusiness", FieldTypeEnum.COMBO_LINK_BUSINESS.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9640, 1, 0),
    JXC_COMMUNICATE_BUSINESS("text_25", "enum.allField.attrName.jxc_communicate_business", "jxcCommunicateBusiness", FieldTypeEnum.COMBO_LINK_BUSINESS.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9630, 1, 0),
    COMMUNICATE_BUSINESS_TYPE("text_26", "enum.allField.attrName.communicate_business_type", "communicateBusinessType", FieldTypeEnum.NUM.getType(), 3, 1, 0, ShowTypeEnum.NONE.getCode(), 9620, 1, 0),
    COMMUNICATE_BUSINESS_LINK_TEXT("text_27", "enum.allField.attrName.communicate_business_link_text", "communicateBusinessLinkText", FieldTypeEnum.TEXT.getType(), 3, 1, 0, ShowTypeEnum.NONE.getCode(), 9610, 1, 0),
    NEXT_PLAN("text_28", "enum.allField.attrName.next_plan", "nextPlan", FieldTypeEnum.SUB_FORM.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9600, 1, 0),
    EXECUTOR_LINKED_TEXT("array_2", "enum.allField.attrName.executor_linked_text", "executorLinkedText", FieldTypeEnum.USER_GROUP.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9590, 1, 0),
    ;


    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see com.xbongbong.paas.enums.FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式详见
     *
     * @see com.xbongbong.saas.enums.ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;

    AllFieldEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                Integer editHide, Integer showType, Integer sort, Integer visible, Integer required) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
